import React, { useState } from 'react'
import store from '../store'
import {incrementAge, decrementAge,changePerson, asyncIncrementAge} from "../actions"
export default function Person() {
  const {name, age} =store.getState()
  const [isTrue, setIsTrue] = useState(false)
  store.subscribe(()=>{
    setIsTrue(!isTrue)
  })
  return (
    <div>
      <h1>Redux信息展示</h1>
      <h2>人物信息:姓名:{name},年龄:{age}</h2>
      <button onClick={()=>store.dispatch(incrementAge())}>增加年龄</button>
      <button onClick={()=>store.dispatch(decrementAge())}>减小</button>
      <button onClick={()=>store.dispatch(changePerson({name:'夏', age:3}))}>换人</button>
      <button onClick={()=>store.dispatch(asyncIncrementAge())}>异步添加年龄</button>

    </div>
  )
}
